package com.kye.express.business.customer_intro.detail;

import android.content.Context;
import android.databinding.DataBindingUtil;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.kye.express.R;
import com.kye.express.databinding.ItemCustomerIntroDetailBinding;
import com.kye.express.utils.StringUtils;
import com.kye.model.bean.customer_intro.GetCustomerIntroDetailResultBean;

class CustomerIntroDetailListItemViewBinder extends me.drakeet.multitype.ItemViewBinder<GetCustomerIntroDetailResultBean.DatasBean, CustomerIntroDetailListItemViewBinder.ViewHolder> {

    private Context mContext;

    public CustomerIntroDetailListItemViewBinder(Context context) {
        mContext = context;
    }

    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        View view = inflater.inflate(R.layout.item_customer_intro_detail, parent, false);
        return new ViewHolder(view);
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull GetCustomerIntroDetailResultBean.DatasBean item) {
        holder.bindData(item);
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        private GetCustomerIntroDetailResultBean.DatasBean data;
        ItemCustomerIntroDetailBinding dataBinding;

        public ViewHolder(View itemView) {
            super(itemView);
            dataBinding = DataBindingUtil.bind(itemView);
        }


        public void bindData(GetCustomerIntroDetailResultBean.DatasBean item) {
            data = item;
            if (data != null) {
                dataBinding.setData(data);
                dataBinding.tvTitle.setText(StringUtils.checkStringIsNull(data.getNoteTime())+" 跟进情况");
            }
        }
    }
}
